package com.renatn.yach.dao.jpa;

import com.renatn.yach.dao.YachItemDao;
import com.renatn.yach.domain.YachItem;
import org.springframework.stereotype.Repository;

import javax.persistence.TypedQuery;
import java.util.List;

/**
 * User: rnasyrov
 * Date: 10.01.12
 * Time: 16:57
 */

@Repository("yachItemDao")
public class YachItemDaoJpa extends GenericDaoJpa<YachItem> implements YachItemDao {

    public YachItemDaoJpa() {
        super(YachItem.class);
    }

    @Override
    public List<YachItem> getByListId(Long listId) {
        TypedQuery<YachItem> query = entityManager.createQuery("SELECT i FROM YachItem i WHERE list_id = :listId", YachItem.class);
        query.setParameter("listId", listId);
        return query.getResultList();
    }
}
